import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as express from 'express';
import * as path from 'path';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  // app.use('/uploads', express.static(path.join('.', 'static')));
  // 修改静态文件路径处理
  app.use('/uploads', express.static(path.join(__dirname, 'static'))); // 使用__dirname确保打包后路径正确

  // 添加异常捕获（针对打包后环境）
  process.on('uncaughtException', (err) => {
    console.error('Uncaught Exception:', err);
  });
  process.on('unhandledRejection', (reason, promise) => {
    console.error('Unhandled Rejection at:', promise, 'reason:', reason);
  });

  await app.listen(33300);

  console.log(33300);
  // await app.listen(process.env.PORT ?? 3000);
}
bootstrap();
